package huoye.shops.huoye.operation.widget;

import android.content.Context;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.codeideology.android.widget.ios.dialog.base.BaseDialog;

import huoye.shops.R;
import huoye.shops.base.BaseCustomDialog;

import static huoye.shops.huoye.operation.activity.ManageProductActivity.TYPE_SELECT_SHOP_ATTRIBUTE_HK;
import static huoye.shops.huoye.operation.activity.ManageProductActivity.TYPE_SELECT_SHOP_ATTRIBUTE_LM;
import static huoye.shops.huoye.operation.activity.ManageProductActivity.TYPE_SELECT_SHOP_ATTRIBUTE_NEW_USER;
import static huoye.shops.huoye.operation.activity.ManageProductActivity.TYPE_SELECT_SHOP_ATTRIBUTE_SHOW;


/**
 * Created by uesr on 2018/8/11.
 */

public class SelectShopAttributeDialog extends BaseDialog<SelectShopAttributeDialog>{



    private Context mContext;
    private ImageView ivOut;
    private TextView tvLm;
    private TextView tvHk;
    private TextView tvNewUser;
    private TextView tvShow;

    private int iCardType;

    public SelectShopAttributeDialog(Context context,int iCardType) {
        super(context);
        this.mContext = context;
        this.iCardType = iCardType;
    }

    @Override
    public View onCreateView() {
        widthScale(0.75f);
        View inflate = View.inflate(context,R.layout.dialog_select_shop_attribute, null);

        ivOut = (ImageView) inflate.findViewById(R.id.dialog_select_shop_iv_out);




        tvHk = (TextView) inflate.findViewById(R.id.dialog_select_shop_tv_hk);
        tvLm = (TextView) inflate.findViewById(R.id.dialog_select_shop_tv_lm);
        tvNewUser = (TextView) inflate.findViewById(R.id.dialog_select_shop_tv_new_user);
        tvShow = (TextView) inflate.findViewById(R.id.dialog_select_shop_tv_show);


        switch (iCardType){
            case 0:
                //未加入
                tvHk.setVisibility(View.GONE);
                tvLm.setVisibility(View.GONE);
                break;
            case 1:
                //联盟商家
                tvHk.setVisibility(View.GONE);
                break;
            case 2:
                //黑卡用户
                tvLm.setVisibility(View.GONE);
                break;
        }

        return inflate;
    }

    @Override
    public void setUiBeforShow() {
        ivOut.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dismiss();
            }
        });
        tvLm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                listener.onSelectShopAttributeClick(TYPE_SELECT_SHOP_ATTRIBUTE_LM);
                dismiss();
            }
        });
        tvHk.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                listener.onSelectShopAttributeClick(TYPE_SELECT_SHOP_ATTRIBUTE_HK);
                dismiss();
            }
        });
        tvNewUser.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                listener.onSelectShopAttributeClick(TYPE_SELECT_SHOP_ATTRIBUTE_NEW_USER);
                dismiss();
            }
        });
        tvShow.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                listener.onSelectShopAttributeClick(TYPE_SELECT_SHOP_ATTRIBUTE_SHOW);
                dismiss();
            }
        });
    }





    public interface OnSelectShopAttributeListener {
        void onSelectShopAttributeClick(int shopType);
    }


    public void setOnSelectShopAttributeListener(OnSelectShopAttributeListener onListener) {
        this.listener = onListener;
    }

    private OnSelectShopAttributeListener listener;
}
